﻿
#ifndef __VWAH_ALGO_HARDWARE_EVENT_H
#define __VWAH_ALGO_HARDWARE_EVENT_H

#include "cmd.h"
//下位机流程的开始和关闭
//isRun-true --下位机流程开��?(下降)
//isRun -false --下位机流程的结束（通车，回收采集蛋��?
//deviceLocation --1 左舵
//deviceLocation --2 右舵
typedef struct _process_control{		
	bool isRun;		
	bool isCarWindowDetect;
    int deviceLocation;
    _process_control(){
		memset(this, 0, sizeof(_process_control));
	}
}process_control;

//灯光颜色
// 0 -灭灯  1 -红灯 2- 绿灯  3 -白灯
typedef struct _light_color{		
	int lightColor;			
    _light_color(){
		memset(this, 0, sizeof(_light_color));
	}
}light_color;

// 升降机高度控制
// isControl -true 业务逻辑控制硬件控制（右舵）
// isControl -false 硬件控制上报给业务逻辑（左舵）
//steps --32位无符号整数 ，下位机步数
typedef struct _lifter_steps{
	bool isControl;
	uint32_t steps ;
    _lifter_steps(){
		memset(this, 0, sizeof(_lifter_steps));
	}
}lifter_steps;

//乘车人数申报
typedef struct _passenger_num{
    int numPeg;
    _passenger_num(){
        memset(this, 0, sizeof(_passenger_num));
    }
}passenger_num;

//回缩按键状态上报
//btnstatus ---1-按下  0 --未按下
typedef struct _status_of_rollback_btn{
    bool btnStatus;

    _status_of_rollback_btn(){
        memset(this, 0, sizeof(_status_of_rollback_btn));
    }
}status_of_rollback_btn;


//升降机和采集蛋状态
//liftStatus 0:：初始状态。1：下降（到顶）;2：上升（到顶）；3：点动上。4点动下。
// EggStatus 0：初始：1:上升到位。2：下降中。3：下降到位。4：前进前半段。5：前进后半段。6：前进到位。7：后退前半段。8：后退后半段。9：后退到位。a：上升中
typedef struct _status_of_lifter{
    int liftStatus;
	int EggStatus;

    _status_of_lifter(){
        memset(this, 0, sizeof(_status_of_lifter));
    }
}status_of_lifter;


//左右舵位置
//location 1-左舵
//location 2- 右舵
typedef struct _device_location{
    int location;

    _device_location(){
        memset(this, 0, sizeof(_device_location));
    }
}device_location;


//离车距离
    // int motorDescent;  --升降机运动多少米 
    // int widthDistance; --采集蛋距车多远（宽）
typedef struct _vehicle_distance
{
    int motorDescent;
    int widthDistance;
  _vehicle_distance()
    {
        memset(this, 0, sizeof(_vehicle_distance));
    }

} vehicle_distance;


 //   ------------------------------------------------------------

//下位机流程的控制
typedef struct _hardware_process_control{		
	EventInfo cmd;
    process_control data;
	_hardware_process_control(){
		cmd.cmd_code = CMD_COMMAND_HW_CONTROL;
	}
}hardware_process_control;

//车窗识别算法是识别成功，设备伸出
typedef struct _hardware_algo_detected{		
	EventInfo cmd;
	_hardware_algo_detected(){
		cmd.cmd_code = CMD_COMMAND_ALGO_DETECT_SUCCEED;
	}
}hardware_algo_detected;

//状态灯控制
typedef struct _hardware_light_control{
	EventInfo cmd ;
	light_color data;
		_hardware_light_control(){
		cmd.cmd_code = CMD_COMMAND_LIGHT_CONTROL;
	}
}hardware_light_control;

//下位机高度控制
typedef struct _hardware_lifter_steps{
	EventInfo cmd ;
	lifter_steps data;
		_hardware_lifter_steps(){
		cmd.cmd_code = CMD_COMMAND_LIFTER_STEPS;
	}
}hardware_lifter_steps;


//乘车人数
typedef struct _hardware_passenger_num{
    EventInfo cmd ;
    passenger_num data;
    _hardware_passenger_num(){
        cmd.cmd_code = CMD_COMMAND_PASSENGER_NUM;
    }
}hardware_passenger_num;


//按下回退按钮事件
typedef struct _hardware_btn_status{
    EventInfo cmd ;
    _hardware_btn_status(){
        cmd.cmd_code = CMD_COMMAND_ROLLBACKBTN_STATUS;
    }
}hardware_btn_status;


//采集蛋伸出到位事件
typedef struct _hardware_protrude_into{
    EventInfo cmd ;
    _hardware_protrude_into(){
        cmd.cmd_code = CMD_COMMAND_GATHER_EGG_INTO_PLACE;
    }
}hardware_protrude_into;


//下位机报警码数据上报
//code -根据硬件协议查询确认
typedef struct _hardware_error_code{
    EventInfo cmd ;
	int code;
    _hardware_error_code(){
        cmd.cmd_code = CMD_COMMAND_ALARM_LIGHT_EVENT;
    }
}hardware_error_code;


//下位机流程开始后定时上传升降机和采集蛋状态
typedef struct _hardware_report_data {
    EventInfo cmd ;
	status_of_lifter data;
    _hardware_report_data(){
        cmd.cmd_code = CMD_COMMAND_HARDWARE_EGG_STATUS;
    }
}hardware_report_data;

//升降机上升
typedef struct _hardware_lifter_rise{
    EventInfo cmd ;
    _hardware_lifter_rise(){
        cmd.cmd_code = CMD_COMMAND_LIFTER_MOTION_RISE;
    }
}hardware_lifter_rise;

//升降机下降
typedef struct _hardware_lifter_descent{
    EventInfo cmd ;
    _hardware_lifter_descent(){
        cmd.cmd_code = CMD_COMMAND_LIFTER_MOTION_DESCENT;
    }
}hardware_lifter_descent;

// connectStatus -true 已连接
// connectStatus -false 断开连接
typedef struct _hardware_connect_status
{
    EventInfo cmd;
    bool connectStatus;
} hardware_connect_status;



//跟算法相关的指令结构体
//cmd :CMD_COMMAND_ALGO_START_DETECT 算法开始（升降机->算法）
//左右舵信息放到device_location 结构体里面，
//CMD_COMMAND_ALGO_END_DETECT        算法结束（升降机->算法）
//CMD_COMMAND_ALGO_TIMEOUT           算法超时之后的广播（算法->升降机）
//CMD_COMMAND_ALGO_CONTROL_START     上位机通知算法--开始监听
typedef struct _hw_algo_cmd{
    EventInfo cmd ;
    device_location data;
}hw_algo_cmd;

// 升降机升降到位后伸出时上报运动的高度和离车距离
typedef struct _far_from_car
{
    EventInfo cmd;
    vehicle_distance data;
    _far_from_car()
    {
        cmd.cmd_code = CMD_COMMAND_HW_FAR_FROM_CAR;
    }
} far_from_car;




#endif
